package run;

import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;

import logic.Logica;

import org.dyno.visual.swing.layouts.Bilateral;
import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;
import org.dyno.visual.swing.layouts.Trailing;

//VS4E -- DO NOT REMOVE THIS LINE!
public class Start extends JFrame {

	private static final long serialVersionUID = 1L;
	/*Panel de tabs*/
	private JTabbedPane jTabbedPane0;
	/*Tab 1*/
	private JPanel jPanel0;
	/*Panel de funciones*/
	private JPanel jPanel2;
	private JLabel jLabel0;
	private JButton jButton0;
	private JButton jButton1;
	private JButton jButton2;
	private JButton jButton3;
	private JButton jButton22;
	/*Panel de operaciones*/
	private JPanel jPanel3;
	private JLabel jLabel1;
	private JButton jButton4;
	private JButton jButton5;
	private JButton jButton6;
	private JButton jButton7;
	private JButton jButton8;
	/*Panel de numeros y variables*/
	private JPanel jPanel4;
	private JButton jButton9;
	private JButton jButton10;
	private JButton jButton11;
	private JButton jButton12;
	private JButton jButton13;
	private JButton jButton14;
	private JButton jButton15;
	private JButton jButton16;
	private JButton jButton17;
	private JButton jButton18;
	private JButton jButton19;
	private JButton jButton20;
	private JButton jButton21;
	/*objetos para funciones y realizar calculo*/
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JButton jButton23;
	/*Datos de intervalo*/
	private JPanel jPanel5;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JLabel jLabel6;
	private JLabel jLabel7;
	private JTextField jTextField0;
	private JTextField jTextField1;
	/*boton para calculo*/
	private JButton jButton24;
	
	/*Tab 2*/
	private JPanel jPanel1;
	
	
	boolean isSin = false;
	boolean isCos = false;
	boolean isTan = false;
	boolean isEuler = false;
	boolean isN = false;
	boolean isExpo = false;
	boolean isX = false;
	boolean isY = false;
	
	ArrayList<String> ecuacion = new ArrayList<String>();
	StringBuilder numero = new StringBuilder();
	private JPanel jPanel6;
	private JLabel jLabel8;
	
	private JLabel jLabel9;
	private JLabel jLabel10;
	private JTextField jTextField2;
	private JLabel jLabel11;
	private JTextField jTextField3;
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	public Start() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJTabbedPane0(), new Constraints(new Bilateral(12, 12, 5), new Bilateral(12, 12, 339)));
		setSize(440, 419);
	}

	private JTextField getJTextField3() {
		if (jTextField3 == null) {
			jTextField3 = new JTextField();
		}
		return jTextField3;
	}

	private JLabel getJLabel11() {
		if (jLabel11 == null) {
			jLabel11 = new JLabel();
			jLabel11.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel11.setText("n=");
		}
		return jLabel11;
	}

	private JTextField getJTextField2() {
		if (jTextField2 == null) {
			jTextField2 = new JTextField();
		}
		return jTextField2;
	}

	private JLabel getJLabel10() {
		if (jLabel10 == null) {
			jLabel10 = new JLabel();
			jLabel10.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel10.setText(")=");
		}
		return jLabel10;
	}

	private JLabel getJLabel9() {
		if (jLabel9 == null) {
			jLabel9 = new JLabel();
			jLabel9.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel9.setText("Y= (");
		}
		return jLabel9;
	}

	private JLabel getJLabel8() {
		if (jLabel8 == null) {
			jLabel8 = new JLabel();
			jLabel8.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel8.setText("Y(");
		}
		return jLabel8;
	}

	private JPanel getJPanel6() {
		if (jPanel6 == null) {
			jPanel6 = new JPanel();
			jPanel6.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
			jPanel6.setLayout(new GroupLayout());
			jPanel6.add(getJLabel8(), new Constraints(new Leading(8, 24, 10, 10), new Leading(12, 12, 12)));
			jPanel6.add(getJLabel9(), new Constraints(new Leading(26, 10, 10), new Leading(12, 12, 12)));
			jPanel6.add(getJLabel10(), new Constraints(new Leading(67, 25, 10, 10), new Leading(12, 12, 12)));
			jPanel6.add(getJTextField2(), new Constraints(new Leading(96, 61, 10, 10), new Leading(15, 12, 12)));
			jPanel6.add(getJLabel11(), new Constraints(new Leading(163, 31, 10, 10), new Leading(15, 12, 12)));
			jPanel6.add(getJTextField3(), new Constraints(new Leading(190, 43, 10, 10), new Leading(15, 12, 12)));
		}
		return jPanel6;
	}

	private JTabbedPane getJTabbedPane0() {
		if (jTabbedPane0 == null) {
			jTabbedPane0 = new JTabbedPane();
			jTabbedPane0.addTab("jPanel0", getJPanel0());
			jTabbedPane0.addTab("jPanel1", getJPanel1());
		}
		return jTabbedPane0;
	}
	
	private JPanel getJPanel0() {
		if (jPanel0 == null) {
			jPanel0 = new JPanel();
			jPanel0.setLayout(new GroupLayout());
			jPanel0.add(getJPanel2(), new Constraints(new Leading(12, 115, 10, 10), new Leading(10, 174, 12, 12)));
			jPanel0.add(getJPanel3(), new Constraints(new Leading(145, 99, 10, 10), new Leading(12, 172, 12, 12)));
			jPanel0.add(getJPanel4(), new Constraints(new Leading(262, 140, 10, 10), new Leading(12, 173, 10, 10)));
			jPanel0.add(getJLabel2(), new Constraints(new Leading(16, 10, 10), new Leading(190, 30, 10, 10)));
			jPanel0.add(getJLabel3(), new Constraints(new Leading(51, 351, 12, 12), new Leading(194, 24, 12, 12)));
			jPanel0.add(getJButton23(), new Constraints(new Trailing(12, 12, 12), new Leading(222, 10, 10)));
			jPanel0.add(getJPanel5(), new Constraints(new Leading(16, 160, 10, 10), new Leading(236, 65, 10, 10)));
			jPanel0.add(getJButton24(), new Constraints(new Leading(264, 137, 12, 12), new Leading(257, 10, 10)));
			jPanel0.add(getJPanel6(), new Constraints(new Leading(16, 244, 12, 12), new Leading(305, 58, 10, 10)));
		}
		return jPanel0;
	}

	private JPanel getJPanel2() {
		if (jPanel2 == null) {
			jPanel2 = new JPanel();
			jPanel2.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
			jPanel2.setLayout(new GroupLayout());
			jPanel2.add(getJLabel0(), new Constraints(new Bilateral(-2, 0, 61), new Leading(-2, 10, 10)));
			jPanel2.add(getJButton0(), new Constraints(new Leading(2, 102, 12, 12), new Leading(20, 12, 12)));
			jPanel2.add(getJButton1(), new Constraints(new Leading(2, 102, 12, 12), new Leading(50, 12, 12)));
			jPanel2.add(getJButton2(), new Constraints(new Leading(2, 12, 12), new Leading(80, 10, 10)));
			jPanel2.add(getJButton3(), new Constraints(new Leading(2, 102, 12, 12), new Leading(109, 10, 10)));
			jPanel2.add(getJButton22(), new Constraints(new Leading(2, 102, 12, 12), new Leading(139, 10, 10)));
		}
		return jPanel2;
	}

	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel0.setText("Funciones:");
		}
		return jLabel0;
	}
	
	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Seno(n)");
			jButton0.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton0MouseMouseClicked(event);
				}
			});
		}
		return jButton0;
	}
	
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Coseno(n)");
			jButton1.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton1MouseMouseClicked(event);
				}
			});
		}
		return jButton1;
	}
	
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setText("Tangente(n)");
			jButton2.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton2MouseMouseClicked(event);
				}
			});
		}
		return jButton2;
	}
	
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setText("Euler(n)");
			jButton3.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton3MouseMouseClicked(event);
				}
			});
		}
		return jButton3;
	}
	
	private JButton getJButton22() {
		if (jButton22 == null) {
			jButton22 = new JButton();
			jButton22.setText("n");
			jButton22.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton22MouseMouseClicked(event);
				}
			});
		}
		return jButton22;
	}
	
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			jPanel3 = new JPanel();
			jPanel3.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
			jPanel3.setLayout(new GroupLayout());
			jPanel3.add(getJLabel1(), new Constraints(new Leading(0, 92, 12, 12), new Leading(0, 12, 12)));
			jPanel3.add(getJButton4(), new Constraints(new Leading(2, 12, 12), new Leading(22, 12, 12)));
			jPanel3.add(getJButton5(), new Constraints(new Leading(2, 41, 12, 12), new Leading(52, 10, 10)));
			jPanel3.add(getJButton6(), new Constraints(new Leading(49, 41, 12, 12), new Leading(22, 12, 12)));
			jPanel3.add(getJButton7(), new Constraints(new Leading(49, 41, 12, 12), new Leading(52, 12, 12)));
			jPanel3.add(getJButton8(), new Constraints(new Leading(2, 88, 12, 12), new Leading(81, 10, 10)));
		}
		return jPanel3;
	}
	
	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel1.setText("Operaciones:");
		}
		return jLabel1;
	}
	
	private JButton getJButton4() {
		if (jButton4 == null) {
			jButton4 = new JButton();
			jButton4.setText("+");
			jButton4.setEnabled(false);
			jButton4.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton4MouseMouseClicked(event);
				}
			});
		}
		return jButton4;
	}

	private JButton getJButton5() {
		if (jButton5 == null) {
			jButton5 = new JButton();
			jButton5.setText("-");
			jButton5.setEnabled(false);
			jButton5.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton5MouseMouseClicked(event);
				}
			});
		}
		return jButton5;
	}

	private JButton getJButton6() {
		if (jButton6 == null) {
			jButton6 = new JButton();
			jButton6.setText("*");
			jButton6.setEnabled(false);
			jButton6.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton6MouseMouseClicked(event);
				}
			});
		}
		return jButton6;
	}

	private JButton getJButton7() {
		if (jButton7 == null) {
			jButton7 = new JButton();
			jButton7.setText("/");
			jButton7.setEnabled(false);
			jButton7.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton7MouseMouseClicked(event);
				}
			});
		}
		return jButton7;
	}

	private JButton getJButton8() {
		if (jButton8 == null) {
			jButton8 = new JButton();
			jButton8.setText("^");
			jButton8.setEnabled(false);
			jButton8.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton8MouseMouseClicked(event);
				}
			});
		}
		return jButton8;
	}

	private JPanel getJPanel4() {
		if (jPanel4 == null) {
			jPanel4 = new JPanel();
			jPanel4.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
			jPanel4.setLayout(new GroupLayout());
			jPanel4.add(getJButton9(), new Constraints(new Leading(0, 12, 12), new Leading(19, 10, 10)));
			jPanel4.add(getJButton10(), new Constraints(new Leading(45, 10, 10), new Leading(19, 12, 12)));
			jPanel4.add(getJButton12(), new Constraints(new Leading(0, 12, 12), new Leading(51, 12, 12)));
			jPanel4.add(getJButton13(), new Constraints(new Leading(45, 12, 12), new Leading(51, 12, 12)));
			jPanel4.add(getJButton15(), new Constraints(new Leading(0, 12, 12), new Leading(81, 10, 10)));
			jPanel4.add(getJButton17(), new Constraints(new Leading(89, 10, 10), new Leading(81, 12, 12)));
			jPanel4.add(getJButton16(), new Constraints(new Leading(45, 12, 12), new Leading(81, 12, 12)));
			jPanel4.add(getJButton14(), new Constraints(new Leading(89, 12, 12), new Leading(51, 12, 12)));
			jPanel4.add(getJButton11(), new Constraints(new Leading(89, 12, 12), new Leading(19, 12, 12)));
			jPanel4.add(getJButton18(), new Constraints(new Leading(0, 12, 12), new Leading(109, 10, 10)));
			jPanel4.add(getJButton19(), new Constraints(new Leading(45, 12, 12), new Leading(109, 12, 12)));
			jPanel4.add(getJButton20(), new Constraints(new Leading(89, 41, 12, 12), new Leading(109, 12, 12)));
			jPanel4.add(getJButton21(), new Constraints(new Leading(28, 12, 12), new Leading(138, 10, 10)));
		}
		return jPanel4;
	}
	
	private JButton getJButton9() {
		if (jButton9 == null) {
			jButton9 = new JButton();
			jButton9.setText("1");
			jButton9.setEnabled(false);
			jButton9.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton9MouseMouseClicked(event);
				}
			});
		}
		return jButton9;
	}

	private JButton getJButton10() {
		if (jButton10 == null) {
			jButton10 = new JButton();
			jButton10.setText("2");
			jButton10.setEnabled(false);
			jButton10.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton10MouseMouseClicked(event);
				}
			});
		}
		return jButton10;
	}

	private JButton getJButton11() {
		if (jButton11 == null) {
			jButton11 = new JButton();
			jButton11.setText("3");
			jButton11.setEnabled(false);
			jButton11.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton11MouseMouseClicked(event);
				}
			});
		}
		return jButton11;
	}

	private JButton getJButton12() {
		if (jButton12 == null) {
			jButton12 = new JButton();
			jButton12.setText("4");
			jButton12.setEnabled(false);
			jButton12.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton12MouseMouseClicked(event);
				}
			});
		}
		return jButton12;
	}

	private JButton getJButton13() {
		if (jButton13 == null) {
			jButton13 = new JButton();
			jButton13.setText("5");
			jButton13.setEnabled(false);
			jButton13.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton13MouseMouseClicked(event);
				}
			});
		}
		return jButton13;
	}

	private JButton getJButton14() {
		if (jButton14 == null) {
			jButton14 = new JButton();
			jButton14.setText("6");
			jButton14.setEnabled(false);
			jButton14.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton14MouseMouseClicked(event);
				}
			});
		}
		return jButton14;
	}

	private JButton getJButton15() {
		if (jButton15 == null) {
			jButton15 = new JButton();
			jButton15.setText("7");
			jButton15.setEnabled(false);
			jButton15.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton15MouseMouseClicked(event);
				}
			});
		}
		return jButton15;
	}

	private JButton getJButton16() {
		if (jButton16 == null) {
			jButton16 = new JButton();
			jButton16.setText("8");
			jButton16.setEnabled(false);
			jButton16.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton16MouseMouseClicked(event);
				}
			});
		}
		return jButton16;
	}

	private JButton getJButton17() {
		if (jButton17 == null) {
			jButton17 = new JButton();
			jButton17.setText("9");
			jButton17.setEnabled(false);
			jButton17.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton17MouseMouseClicked(event);
				}
			});
		}
		return jButton17;
	}

	private JButton getJButton18() {
		if (jButton18 == null) {
			jButton18 = new JButton();
			jButton18.setText("0");
			jButton18.setEnabled(false);
			jButton18.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton18MouseMouseClicked(event);
				}
			});
		}
		return jButton18;
	}

	private JButton getJButton19() {
		if (jButton19 == null) {
			jButton19 = new JButton();
			jButton19.setText("x");
			jButton19.setEnabled(false);
			jButton19.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton19MouseMouseClicked(event);
				}
			});
		}
		return jButton19;
	}

	private JButton getJButton20() {
		if (jButton20 == null) {
			jButton20 = new JButton();
			jButton20.setText("y");
			jButton20.setEnabled(false);
			jButton20.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton20MouseMouseClicked(event);
				}
			});
		}
		return jButton20;
	}
	
	private JButton getJButton21() {
		if (jButton21 == null) {
			jButton21 = new JButton();
			jButton21.setText("HECHO");
			jButton21.setEnabled(false);
			jButton21.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton21MouseMouseClicked(event);
				}
			});
		}
		return jButton21;
	}

	private JLabel getJLabel2() {
		if (jLabel2 == null) {
			jLabel2 = new JLabel();
			jLabel2.setFont(new Font("Tahoma", Font.BOLD, 16));
			jLabel2.setText("Y' = ");
		}
		return jLabel2;
	}
	
	private JLabel getJLabel3() {
		if (jLabel3 == null) {
			jLabel3 = new JLabel();
		}
		return jLabel3;
	}
	
	private JButton getJButton23() {
		if (jButton23 == null) {
			jButton23 = new JButton();
			jButton23.setText("Bien, Dar intervalo");
			jButton23.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton23MouseMouseClicked(event);
				}
			});
		}
		return jButton23;
	}

	private JPanel getJPanel5() {
		if (jPanel5 == null) {
			jPanel5 = new JPanel();
			jPanel5.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
			jPanel5.setLayout(new GroupLayout());
			jPanel5.add(getJLabel4(), new Constraints(new Leading(3, 144, 12, 12), new Leading(3, 12, 12)));
			jPanel5.add(getJLabel5(), new Constraints(new Leading(5, 10, 10), new Leading(28, 12, 12)));
			jPanel5.add(getJLabel7(), new Constraints(new Leading(139, 10, 10), new Leading(28, 12, 12)));
			jPanel5.add(getJTextField0(), new Constraints(new Leading(17, 51, 10, 10), new Leading(31, 12, 12)));
			jPanel5.add(getJTextField1(), new Constraints(new Leading(86, 51, 91, 91), new Leading(31, 12, 12)));
			jPanel5.add(getJLabel6(), new Constraints(new Leading(69, 16, 10, 10), new Leading(28, 12, 12)));
		}
		return jPanel5;
	}

	private JButton getJButton24() {
		if (jButton24 == null) {
			jButton24 = new JButton();
			jButton24.setText("Calcular");
			jButton24.setVisible(false);
			jButton24.addMouseListener(new MouseAdapter() {
				
				public void mouseClicked(MouseEvent event) {
					jButton24MouseMouseClicked(event);
				}
			});
		}
		return jButton24;
	}

	private JLabel getJLabel4() {
		if (jLabel4 == null) {
			jLabel4 = new JLabel();
			jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel4.setText("Intervalo");
		}
		return jLabel4;
	}

	private JLabel getJLabel5() {
		if (jLabel5 == null) {
			jLabel5 = new JLabel();
			jLabel5.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel5.setText("[");
		}
		return jLabel5;
	}
	
	private JLabel getJLabel6() {
		if (jLabel6 == null) {
			jLabel6 = new JLabel();
			jLabel6.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel6.setText(";");
		}
		return jLabel6;
	}
	
	private JLabel getJLabel7() {
		if (jLabel7 == null) {
			jLabel7 = new JLabel();
			jLabel7.setFont(new Font("Tahoma", Font.BOLD, 18));
			jLabel7.setText("]");
		}
		return jLabel7;
	}
	
	private JTextField getJTextField0() {
		if (jTextField0 == null) {
			jTextField0 = new JTextField();
			jTextField0.setHorizontalAlignment(SwingConstants.CENTER);
			jTextField0.setToolTipText("Indicador decimal Punto (.)");
		}
		return jTextField0;
	}

	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
			jTextField1.setHorizontalAlignment(SwingConstants.CENTER);
			jTextField1.setToolTipText("Indicador decimal Punto (.)");
		}
		return jTextField1;
	}

	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.setVisible(false);
			jPanel1.setLayout(new GroupLayout());
		}
		return jPanel1;
	}

	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				Start frame = new Start();
				frame.setDefaultCloseOperation(Start.EXIT_ON_CLOSE);
				frame.setTitle("Start");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}

	private void jButton0MouseMouseClicked(MouseEvent event) {
		activeNum();
		inactiveSin();
		isSin = true;
		jLabel3.setText(jLabel3.getText()+"SIN(");
		ecuacion.add("SIN");
	}
	
	private void jButton1MouseMouseClicked(MouseEvent event) {
		activeNum();
		inactiveCos();
		isCos = true;
		jLabel3.setText(jLabel3.getText()+"COS(");
		ecuacion.add("COS");
	}
	
	private void jButton2MouseMouseClicked(MouseEvent event) {
		activeNum();
		inactiveTan();
		isTan = true;
		jLabel3.setText(jLabel3.getText()+"TAN(");
		ecuacion.add("TAN");
	}
	
	private void jButton3MouseMouseClicked(MouseEvent event) {
		activeExpOpe();
		isEuler = true;
		jLabel3.setText(jLabel3.getText()+"e");
		ecuacion.add("e");
	}
	
	private void jButton22MouseMouseClicked(MouseEvent event) {
		activeNum();
		inactiveN();
		isN = true;
	}
	
	private void jButton4MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+"+");
		inactiveOpe();
		activeFun();
		inactiveNum();
		ecuacion.add("+");
	}
	
	private void jButton5MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+"-");
		inactiveOpe();
		activeFun();
		inactiveNum();
		ecuacion.add("-");
	}
	
	private void jButton6MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+"*");
		inactiveOpe();
		activeFun();
		inactiveNum();
		ecuacion.add("*");
	}
	
	private void jButton7MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+"/");
		inactiveOpe();
		activeFun();
		inactiveNum();
		ecuacion.add("/");
	}
	
	private void jButton8MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+"^");
		if(!isEuler)
			isExpo = true;
		inactiveOpe();
		inactiveFun();
		activeNum();
		ecuacion.add("^");
	}
	
	private void jButton9MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton9.getText());
		numero.append(jButton9.getText());
	}
	
	private void jButton10MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton10.getText());
		numero.append(jButton10.getText());
	}
	
	private void jButton11MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton11.getText());
		numero.append(jButton11.getText());
	}
	
	private void jButton12MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton12.getText());
		numero.append(jButton12.getText());
	}
	
	private void jButton13MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton13.getText());
		numero.append(jButton13.getText());
	}
	
	private void jButton14MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton14.getText());
		numero.append(jButton14.getText());
	}
	
	private void jButton15MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton15.getText());
		numero.append(jButton15.getText());
	}
	
	private void jButton16MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton16.getText());
		numero.append(jButton16.getText());
	}
	
	private void jButton17MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton17.getText());
		numero.append(jButton17.getText());
	}
	
	private void jButton18MouseMouseClicked(MouseEvent event) {
		jLabel3.setText(jLabel3.getText()+jButton18.getText());
		numero.append(jButton18.getText());
	}
	
	private void jButton19MouseMouseClicked(MouseEvent event) {
		if(!isX && !isY){
			jLabel3.setText(jLabel3.getText()+jButton19.getText());
			ecuacion.add(numero.toString());
			numero = new StringBuilder();
			ecuacion.add("x");
			inactiveXY();
			isX = true;
		}else{
			JOptionPane.showMessageDialog(null, "Solo es posible una variable (X,Y) por funcion!!!");
		}
	}
	
	private void jButton20MouseMouseClicked(MouseEvent event) {
		if(!isY && !isX){
			jLabel3.setText(jLabel3.getText()+jButton20.getText());
			ecuacion.add(numero.toString());
			numero = new StringBuilder();
			ecuacion.add("y");
			inactiveXY();
			isY = true;
		}else{
			JOptionPane.showMessageDialog(null, "Solo es posible una variable (X,Y) por funcion!!!");
		}
	}
	
	/*BTN_HECHO*/
	private void jButton21MouseMouseClicked(MouseEvent event) {
		if(isSin){
			jLabel3.setText(jLabel3.getText()+")");
			activeOpe();
			inactiveNum();
			inactiveFun();
		}else if(isCos){
			jLabel3.setText(jLabel3.getText()+")");
			activeOpe();
			inactiveNum();
			inactiveFun();
		}else if(isTan){
			jLabel3.setText(jLabel3.getText()+")");
			activeOpe();
			inactiveNum();
			inactiveFun();
		}else if(isEuler){
			activeOpe();
			inactiveNum();
			inactiveFun();
		}else if(isN){
			activeOpe();
			inactiveNum();
			inactiveFun();
		}else if(isExpo){
			activeOpe();
			inactiveNum();
			inactiveFun();
		}
		isSin = false;
		isCos = false;
		isTan = false;
		isEuler = false;
		isN = false;
		isExpo = false;
		isX = false;
		isY = false;
	}
	
	private void jButton23MouseMouseClicked(MouseEvent event) {
		System.out.println("Ecuacion: "+ ecuacion.toString());
		boolean valida = JOptionPane.showConfirmDialog(null, "La funcion a evaluar es esta: Y' = "+jLabel3.getText(), "Funcion a evaluar", 0) == 1 ? false : true; 
		if(valida){
			inactiveFun();
			inactiveOpe();
			inactiveNum();
			jButton23.setVisible(false);
			jPanel5.setVisible(true);
			jButton24.setVisible(true);
		}else{
			ecuacion = new ArrayList<String>();
			numero = new StringBuilder();
			jLabel3.setText("");
			activeFun();
			inactiveOpe();
			inactiveNum();
		}
		
	}
	
	private void jButton24MouseMouseClicked(MouseEvent event) {
		try {
			Double menor = Math.min(Double.parseDouble(jTextField0.getText()), Double.parseDouble(jTextField1.getText())); 
			Double mayor = Math.max(Double.parseDouble(jTextField0.getText()), Double.parseDouble(jTextField1.getText()));
			System.out.println("Mayor:"+mayor+" Menor:"+menor);
			jTextField0.setEnabled(false);
			jTextField1.setEnabled(false);
			jButton24.setEnabled(false);
			Logica logica = new Logica(ecuacion);
			
		} catch (NumberFormatException e) {
			JOptionPane.showMessageDialog(null, "Hay por lo menos un numero no valido.\n - Recuerde que son necesarios los dos numeros\n - Recuerde que el indicador decimal es el punto (.)\n intentelo de nuevo", "Numero no valido", 0);
			e.getMessage();
		} 
		
	}
	
	private void inactiveFun(){
		jButton0.setEnabled(false);
		jButton1.setEnabled(false);
		jButton2.setEnabled(false);
		jButton3.setEnabled(false);
		jButton22.setEnabled(false);
	}
	
	private void activeFun(){
		jButton0.setEnabled(true);
		jButton1.setEnabled(true);
		jButton2.setEnabled(true);
		jButton3.setEnabled(true);
		jButton22.setEnabled(true);
	}
	
	private void inactiveOpe(){
		jButton4.setEnabled(false);
		jButton5.setEnabled(false);
		jButton6.setEnabled(false);
		jButton7.setEnabled(false);
		jButton8.setEnabled(false);
	}
	
	private void activeOpe(){
		jButton4.setEnabled(true);
		jButton5.setEnabled(true);
		jButton6.setEnabled(true);
		jButton7.setEnabled(true);
		jButton8.setEnabled(true);
	}
	
	private void inactiveNum(){
		jButton9.setEnabled(false);
		jButton10.setEnabled(false);
		jButton11.setEnabled(false);
		jButton12.setEnabled(false);
		jButton13.setEnabled(false);
		jButton14.setEnabled(false);
		jButton15.setEnabled(false);
		jButton16.setEnabled(false);
		jButton17.setEnabled(false);
		jButton18.setEnabled(false);
		jButton19.setEnabled(false);
		jButton20.setEnabled(false);
		jButton21.setEnabled(false);
	}
	
	private void activeNum(){
		jButton9.setEnabled(true);
		jButton10.setEnabled(true);
		jButton11.setEnabled(true);
		jButton12.setEnabled(true);
		jButton13.setEnabled(true);
		jButton14.setEnabled(true);
		jButton15.setEnabled(true);
		jButton16.setEnabled(true);
		jButton17.setEnabled(true);
		jButton18.setEnabled(true);
		jButton19.setEnabled(true);
		jButton20.setEnabled(true);
		jButton21.setEnabled(true);
	}
	
	private void inactiveSin(){
		jButton1.setEnabled(false);
		jButton2.setEnabled(false);
		jButton3.setEnabled(false);
		jButton22.setEnabled(false);
	}
	
	private void inactiveCos(){
		jButton0.setEnabled(false);
		jButton2.setEnabled(false);
		jButton3.setEnabled(false);
		jButton22.setEnabled(false);
	}
	
	private void inactiveTan(){
		jButton0.setEnabled(false);
		jButton1.setEnabled(false);
		jButton3.setEnabled(false);
		jButton22.setEnabled(false);
	}
	
	private void inactiveN(){
		jButton0.setEnabled(false);
		jButton1.setEnabled(false);
		jButton2.setEnabled(false);
		jButton3.setEnabled(false);
	}
	
	private void inactiveXY(){
		jButton9.setEnabled(false);
		jButton10.setEnabled(false);
		jButton11.setEnabled(false);
		jButton12.setEnabled(false);
		jButton13.setEnabled(false);
		jButton14.setEnabled(false);
		jButton15.setEnabled(false);
		jButton16.setEnabled(false);
		jButton17.setEnabled(false);
		jButton18.setEnabled(false);
		jButton19.setEnabled(false);
		jButton20.setEnabled(false);
	}
	
	private void activeExpOpe(){
		jButton4.setEnabled(false);
		jButton5.setEnabled(false);
		jButton6.setEnabled(false);
		jButton7.setEnabled(false);
		jButton8.setEnabled(true);
	}

}
